package com.izhaowo.recommend.contrl;


import com.izhaowo.recommend.util.HBaseUtil;
import com.izhaowo.recommend.util.JavaDateUitl;
import com.izhaowo.recommend.vo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;

import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

import static java.util.Objects.isNull;

/**
 * Created by HASEE on 2019/7/22.
 */
public class CombineAction {
    private static final Logger logger = LoggerFactory.getLogger(CombineAction.class);

    static RecommendWeddingPlanner hander = new RecommendWeddingPlanner();

    //@TODO  暂时屏蔽 CRM
    public static List<WorkerQueryInfoVO> getFuzzyWorkersForCrm(String fuzzy, int startAmount, int endAmount) {
        List<WorkerQueryInfoVO> workersList = new ArrayList<>();
        Map<String, List<WorkerVO>> nameWorkers = hander.getNameWorkers(HBaseUtil.getFilterList("0", null, "d677824c-bae7-11e7-99f0-408d5c0cd580"));
        List<String> userIds = new ArrayList<>();
        List<String> workerIds = new ArrayList<>();
        if (null != nameWorkers.get(fuzzy)) {
            for (WorkerVO vo : nameWorkers.get(fuzzy)) {
                if (null != vo.getUserId() && !"".equals(vo.getUserId())) userIds.add(vo.getUserId());
                if (null != vo.getId() && !"".equals(vo.getId())) workerIds.add(vo.getId());
            }

            Map<String, UserVO> userIDVOMap = hander.getUserVO(userIds);
//            Map<String, UserVO> userIDVOMap = hander.getUserVOList2Map(userIds);
            Map<String, List<WorkerServiceVO>> workerIdServiceVOMap = hander.getWorkerServices(workerIds);
            //本月接单
            String thisMonth = JavaDateUitl.dateToStr(new Date()).replaceAll("-", "").substring(0, 6);
            int endMonth = Integer.valueOf(thisMonth.substring(4, 6)) + 1;
            String endYearMonth = thisMonth.substring(0, 4) + (endMonth < 10 ? "0" + endMonth : endMonth);
            Map<String, List<WorkerWeddingOrderVO>> thisMonthOrderMap = hander.getWorkerWeddingOrders(workerIds, thisMonth, endYearMonth, "1"); //create_time
            //本月下单
//            Map<String, WorkerMonthOrderLimitVO> thisMonthWorkerOrderLimitMap = hander.getWorkerMonthOrderLimitsList(workerIds, thisMonth.substring(0, 4), thisMonth.substring(4)); // new Date()
            Map<String, WorkerMonthOrderLimitVO> thisMonthWorkerOrderLimitMap = hander.getWorkerMonthOrderLimits(workerIds, thisMonth.substring(0, 4), thisMonth.substring(4)); // new Date()

            for (WorkerVO workerVO : nameWorkers.get(fuzzy)) {
                //校验档期
                WorkerInfoVO info = formatWorkerSchduleForCrm(workerVO, userIDVOMap,
                        thisMonthWorkerOrderLimitMap.get(workerVO.getId()), thisMonthOrderMap.get(workerVO.getId()), null);
                if (!isNull(info)) {
                    //校验是否存在服务，不存在服务则排除
                    List<WorkerServiceVO> serviceList = workerIdServiceVOMap.get(workerVO.getId());
//					if(!isNull(serviceList) && serviceList.size() > 0){
                    WorkerQueryInfoVO vo = new WorkerQueryInfoVO();
                    BeanUtils.copyProperties(info, vo);
                    vo.setServiceList(serviceList);
                    workersList.add(vo);
                }
            }
        }
        return workersList;
    }

    private static WorkerInfoVO formatWorkerSchduleForCrm(WorkerVO worker, Map<String, UserVO> userMap,
                                                          WorkerMonthOrderLimitVO workerMonthOrderLimitVO,
                                                          List<WorkerWeddingOrderVO> thisMonthOrder, String weddingCityId) {
        WorkerInfoVO info = new WorkerInfoVO();
        BeanUtils.copyProperties(worker, info);
        UserVO user = userMap.get(worker.getUserId());
//        assertNull(user, "用户信息不存在:" + worker.getUserId());
        info.setAvator(user.getAvator());
        info.setMsisdn(user.getMsisdn());
        //校验是否存在档期
        info = verifyWorkerMonthScheduleForCrm(worker, workerMonthOrderLimitVO, thisMonthOrder, info);
        info.setMonthCanOrder(verfyMonthCanOrder(workerMonthOrderLimitVO, thisMonthOrder));
        //校验是否在服务区域
        info.setCityService(verifyWorkerServiceCity(weddingCityId, worker.getServiceCity()));
        return info;
    }

    private static WorkerInfoVO verifyWorkerMonthScheduleForCrm(WorkerVO worker,
                                                                WorkerMonthOrderLimitVO workerMonthOrderLimitVO,
                                                                List<WorkerWeddingOrderVO> thisMonthOrder, WorkerInfoVO info) {
        int canOrderType = 5;
        //0：职服设置0单，1：当天已接单，2：本月接单已满，3：月执行单已满,4：自己设置的休息日,5:可接单
        if (worker.getDailyLimit() == 0) {
            canOrderType = 0;
        }
        //当月接单已满
        if (worker.getDailyType() == 1) {
            canOrderType = 2;
        }
        info.setCanOrderType(canOrderType);
        return info;
    }


    /**
     * check
     *
     * @param fuzzy
     * @param weddingDate
     * @return
     */
    public static List<WorkerQueryInfoVO> getFuzzyWorkers(String fuzzy,
                                                          String weddingDate, String typeStr) {
        List<WorkerQueryInfoVO> workersList = new ArrayList<>();
        Map<String, List<WorkerVO>> nameWorkers = hander.getNameWorkers(HBaseUtil.getFilterList("0", null, "d677824c-bae7-11e7-99f0-408d5c0cd580"));
        List<String> userIds = new ArrayList<>();
        List<String> workerIds = new ArrayList<>();
        if (null != nameWorkers.get(fuzzy)) {
            for (WorkerVO vo : nameWorkers.get(fuzzy)) {
                if (null != vo.getUserId() && !"".equals(vo.getUserId())) userIds.add(vo.getUserId());
                if (null != vo.getId() && !"".equals(vo.getId())) workerIds.add(vo.getId());
            }
            Map<String, UserVO> userIDVOMap = hander.getUserVO(userIds);
//            Map<String, UserVO> userIDVOMap = hander.getUserVOList2Map(userIds);
            Map<String, List<WorkerServiceVO>> workerIdServiceVOMap = hander.getWorkerServices(workerIds);//服务
            Map<String, List<WorkerWeddingOrderVO>> wedMonthOrderMap = hander.getWorkerWeddingOrders(workerIds,
                    weddingDate.substring(0, 6), JavaDateUitl.getNextMonth(weddingDate), "2"); //当月执行
            Map<String, List<WorkerWeddingOrderVO>> thisMonthOrderMap = hander.getWorkerWeddingOrders(workerIds,
                    JavaDateUitl.thisMonth(), JavaDateUitl.nextMonth(), "1"); //本月接单
            Map<String, List<WorkerScheduleVO>> wedMonthWorkerScheduleMap = hander.getWorkerScheduleDates(workerIds,
                    weddingDate.substring(0, 6), JavaDateUitl.getNextMonth(weddingDate));//执行月档期设置

            Map<String, List<WorkerServiceOrderVO>> workerServiceOrderMap = new HashMap<>(); //执行月职业人订单服务
            // Map<String, List<WorkerServiceOrderVO>> workerServiceOrderMap = getWorkerServiceOrderMap(workerIds,
//                    weddingDate, JavaDateUitl.getNextMonth(weddingDate), workerIdServiceVOMap, wedMonthOrderMap); //执行月职业人订单服务

            Map<String, WorkerMonthOrderLimitVO> workerOrderLimitMap = hander.getWorkerMonthOrderLimits(workerIds,
                    weddingDate.substring(0, 4), weddingDate.substring(4, 6)); //职业人限单
//            Map<String, WorkerMonthOrderLimitVO> workerOrderLimitMap = hander.getWorkerMonthOrderLimitsList(workerIds,
//                    weddingDate.substring(0, 4), weddingDate.substring(4, 6)); //职业人限单

            Map<String, WorkerMonthOrderLimitVO> thisMonthWorkerOrderLimitMap = hander.getWorkerMonthOrderLimits(workerIds,
                    JavaDateUitl.thisMonth().substring(0, 4), JavaDateUitl.thisMonth().substring(4, 6)); //本月下单
//            Map<String, WorkerMonthOrderLimitVO> thisMonthWorkerOrderLimitMap = hander.getWorkerMonthOrderLimitsList(workerIds,
//                    JavaDateUitl.thisMonth().substring(0, 4), JavaDateUitl.thisMonth().substring(4, 6)); //本月下单
            List<WorkerVO> listWorkerVo = nameWorkers.get(fuzzy);

            for (WorkerVO workerVo : listWorkerVo) {
//                if (workerVo.getStatus().equals("0")) {
                WorkerQueryInfoVO queryInfoVO = new WorkerQueryInfoVO();
                //职业人执行月每天的档期

                RecommendWeddingPlanner.getWorkerLocation(workerVo);

                Map<String, List<WorkerScheduleVO>> scheduleMap = getScheduleMap(weddingDate, wedMonthWorkerScheduleMap, workerVo);
                WorkerInfoVO info = formatWorkerSchdule(workerVo, weddingDate, null, userIDVOMap,
                        workerOrderLimitMap.get(workerVo.getId()),
                        wedMonthOrderMap.get(workerVo.getId()), thisMonthOrderMap.get(workerVo.getId()),
                        scheduleMap,
                        thisMonthWorkerOrderLimitMap.get(workerVo.getId()), typeStr);
                BeanUtils.copyProperties(info, queryInfoVO);
                //查询接单情况
                queryInfoVO = formatWorkerOrderByMap(queryInfoVO, wedMonthWorkerScheduleMap.get(workerVo.getId()), weddingDate, workerVo,
                        workerIdServiceVOMap.get(workerVo.getId()), workerServiceOrderMap.get(workerVo.getId()));
//					//服务
//					List<WorkerServiceVO> serviceList = workerServiceMap.get(worker.getId());
//					vo.setServiceList(serviceList);
                queryInfoVO.setCanOrder(info.getSchedule());
                workersList.add(queryInfoVO);

            }
//            }
        }
        return workersList;
    }

    public static Map<String, List<WorkerScheduleVO>> getScheduleMap(
            String weddingDate, Map<String, List<WorkerScheduleVO>> monthWorkerScheduleMap, WorkerVO worker) {
        Map<String, List<WorkerScheduleVO>> scheduleMap = new HashMap<>();
        //职业人该月的档期
        List<WorkerScheduleVO> scheduleList = monthWorkerScheduleMap.get(worker.getId());
        if (null != scheduleList && !scheduleList.isEmpty()) {
            //职业人档期按天分配
            scheduleMap = scheduleList.stream().collect(Collectors.groupingBy(WorkerScheduleVO::getScheduleDate));
        }
        return scheduleMap;
    }

    /**
     * check
     *
     * @param workerIds
     * @param weddingDate
     * @param endYearMonth
     * @param workerIdServiceVOMap
     * @param wedMonthOrderMap
     * @return
     */
    public static Map<String, List<WorkerServiceOrderVO>> getWorkerServiceOrderMap(
            List<String> workerIds, String weddingDate, String endYearMonth, Map<String, List<WorkerServiceVO>> workerIdServiceVOMap,
            Map<String, List<WorkerWeddingOrderVO>> wedMonthOrderMap) {
        Map<String, List<WorkerServiceOrderVO>> workerServiceOrderMap = new HashMap<>();
        Map<String, List<UserWeddingTeamMemberVO>> workerIdTeamMembers = hander.getUserWeddingTeamMembers(workerIds,
                weddingDate.substring(0, 6), endYearMonth);
        List<WorkerServiceOrderVO> workerServiceOrderList = new ArrayList<>();
        if (null != wedMonthOrderMap.values() && !wedMonthOrderMap.values().isEmpty()) {
            Iterator<List<WorkerWeddingOrderVO>> it = wedMonthOrderMap.values().iterator();

            while (it.hasNext()) {
                List<WorkerWeddingOrderVO> listVO = it.next();
                for (WorkerWeddingOrderVO orderVO : listVO) {
                    WorkerServiceOrderVO vo = new WorkerServiceOrderVO();
                    List<UserWeddingTeamMemberVO> dayMemberList = workerIdTeamMembers.get(orderVO.getWorkerId());
                    List<WorkerServiceVO> workerServiceList = workerIdServiceVOMap.get(orderVO.getWorkerId());
                    vo.setWorkerId(orderVO.getWorkerId());
                    if (null != dayMemberList && !dayMemberList.isEmpty()) {
                        for (UserWeddingTeamMemberVO member : dayMemberList) {
                            if (member.getWeddingId().equals(orderVO.getWeddingId()) && "2" != orderVO.getWeddingOrderStatus()) {
                                vo.setWorkerServiceId(member.getWorkerServiceId());
                                vo.setServiceName(member.getServiceName());
                                vo.setWeddate(member.getWeddate());
                                if (null != workerServiceList && !workerServiceList.isEmpty()) {
                                    for (WorkerServiceVO service : workerServiceList) {
                                        if (member.getWorkerServiceId().equals(service.getId())) {
                                            vo.setServiceId(service.getServiceId());
                                        }
                                    }
                                }
                                workerServiceOrderList.add(vo);
                            }
                        }
                    }
                }
            }
        }
        if (null != workerServiceOrderList && !workerServiceOrderList.isEmpty()) {
            workerServiceOrderMap = workerServiceOrderList.stream().collect(Collectors.groupingBy(WorkerServiceOrderVO::getWorkerId));
        }
        return workerServiceOrderMap;
    }

    public static WorkerInfoVO formatWorkerSchdule(WorkerVO worker,
                                                   String weddingDate, String weddingCityId, Map<String, UserVO> userMap,
                                                   WorkerMonthOrderLimitVO workerMonthOrderLimitVO,
                                                   List<WorkerWeddingOrderVO> weddingMonthOrder, List<WorkerWeddingOrderVO> thisMonthOrder,
                                                   Map<String, List<WorkerScheduleVO>> scheduleMap,
                                                   WorkerMonthOrderLimitVO thisMonthWorkerMonthOrderLimitVO, String typeStr) {
        WorkerInfoVO info = new WorkerInfoVO();
        BeanUtils.copyProperties(worker, info);
        try {
            UserVO user = userMap.get(worker.getUserId()); // userControllerService.queryUserById(worker.getUserId());
//        assertNull(user, "用户信息不存在:" + worker.getUserId());
            if (null == user) return null;
            info.setAvator(user.getAvator());
            info.setMsisdn(user.getMsisdn());
        } catch (Exception e) {
            logger.info("____ userMap  get user_id is " + worker.getUserId() + " is null");
        }

        //校验是否存在档期
        info = verifyWorkerScheduleNewForDay(weddingDate, worker, workerMonthOrderLimitVO, weddingMonthOrder,
                thisMonthOrder, scheduleMap, thisMonthWorkerMonthOrderLimitVO, info, typeStr);
        info.setMonthCanOrder(verfyMonthCanOrder(thisMonthWorkerMonthOrderLimitVO, thisMonthOrder));
        //校验是否在服务区域
        info.setCityService(verifyWorkerServiceCity(weddingCityId, worker.getServiceCity()));
        return info;
    }

    public static int verfyMonthCanOrder(
            WorkerMonthOrderLimitVO workerMonthOrderLimitVO,
            List<WorkerWeddingOrderVO> thisMonthOrder) {
        int monthCanOrder = 6;
        if (null != workerMonthOrderLimitVO) {
            monthCanOrder = workerMonthOrderLimitVO.getReceiptNum();
        }
        int thisMonthOrders = 0;
        if (null != thisMonthOrder) {
            thisMonthOrders = thisMonthOrder.size();
        }
        if (monthCanOrder >= thisMonthOrders) {
            monthCanOrder = monthCanOrder - thisMonthOrders;
        }
        return monthCanOrder;
    }

    public static int verifyWorkerServiceCity(String weddingCityId, List<WorkerServiceCityVO> list) {
        if (null != list && !list.isEmpty()) {
            for (WorkerServiceCityVO serviceCity : list) {
                if (null != serviceCity.getCityId() && weddingCityId.equals(serviceCity.getCityId())) {
                    return 1;
                }
            }
        }
        return 0;
    }


    /**
     * check
     *
     * @param vo
     * @param list
     * @param weddate
     * @param worker
     * @param serviceList
     * @param workerServiceOrderList
     * @return
     */
    public static WorkerQueryInfoVO formatWorkerOrderByMap(WorkerQueryInfoVO vo, List<WorkerScheduleVO> list,
                                                           String weddate, WorkerVO worker, List<WorkerServiceVO> serviceList,
                                                           List<WorkerServiceOrderVO> workerServiceOrderList) {
        Map<String, List<WorkerScheduleVO>> dayScheduleMap = new HashMap<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        //本月接单量
        int monthOrdered = 0;
        if (null != list && !list.isEmpty()) {
            monthOrdered = list.size();
            for (WorkerScheduleVO workerScheduleVO : list) {
                if (1 == workerScheduleVO.getType() || 2 == workerScheduleVO.getType()) {
                    monthOrdered = monthOrdered - 1;
                }
            }
            dayScheduleMap = list.stream().collect(Collectors.groupingBy(WorkerScheduleVO::getScheduleDate));
        }

        //昨天单量情况
        int yesterdayOrder = 0;
        String yesterday = JavaDateUitl.dateToStr(JavaDateUitl.addDay(JavaDateUitl.strToDate(weddate, sdf), -1));
        if (!isNull(dayScheduleMap.get(yesterday))) {
            List<WorkerScheduleVO> daylist = dayScheduleMap.get(yesterday);
            yesterdayOrder = daylist.size();
            for (WorkerScheduleVO workerScheduleVO : daylist) {
                if (1 == workerScheduleVO.getType() || 2 == workerScheduleVO.getType()) {
                    yesterdayOrder = yesterdayOrder - 1;
                }
            }
//			yesterdayOrder = dayScheduleMap.get(DayUtil.addDay(weddate, -1)).size();
        }
        //明天接单情况
        int tomorrowOrder = 0;
        String tomorrow = JavaDateUitl.dateToStr(JavaDateUitl.addDay(JavaDateUitl.strToDate(weddate, sdf), 1));
        if (!isNull(dayScheduleMap.get(tomorrow))) {
            List<WorkerScheduleVO> daylist = dayScheduleMap.get(tomorrow);
            tomorrowOrder = daylist.size();
            for (WorkerScheduleVO workerScheduleVO : daylist) {
                if (1 == workerScheduleVO.getType() || 2 == workerScheduleVO.getType()) {
                    tomorrowOrder = tomorrowOrder - 1;
                }
            }
        }
        //可接单数
        int canOrder = worker.getDailyLimit();
        if (!isNull(dayScheduleMap.get(weddate))) {
            List<WorkerScheduleVO> daylist = dayScheduleMap.get(weddate);
            canOrder = worker.getDailyLimit() - daylist.size();
            for (WorkerScheduleVO workerScheduleVO : daylist) {
                if (1 == workerScheduleVO.getType() || 2 == workerScheduleVO.getType()) {
                    //@TODO 是这样计算？
                    canOrder = 0;
                }
            }
//			canOrder = worker.getDailyLimit() - dayScheduleMap.get(weddate).size();
        }
        //已接单数
        int orders = 0;
        if (!isNull(dayScheduleMap.get(weddate))) {
            List<WorkerScheduleVO> daylist = dayScheduleMap.get(weddate);
            orders = daylist.size();
            for (WorkerScheduleVO workerScheduleVO : daylist) {
                if (1 == workerScheduleVO.getType() || 2 == workerScheduleVO.getType()) {
                    orders = orders - 1;
                }
            }
//			orders = dayScheduleMap.get(weddate).size();
        }
        //存在服务，并且当天无订单
        int serviceType = 0;

//        if (!isNull(worker.getVocation()) && "统筹师".equals(worker.getVocation()) && !isNull(workerServiceOrderList) && workerServiceOrderList.size() > 0) {
//            if (orders > 0) {
//                for (int i = 0; i < workerServiceOrderList.size(); i++) {
//                    WorkerServiceOrderVO serviceOrder = workerServiceOrderList.get(i);
//                    //非筹备统筹
//                    if ((!isNull(serviceOrder.getServiceId()) && !preparationId.equals(serviceOrder.getServiceId())) || !"筹备统筹".equals(serviceOrder.getServiceName())) {
//                        serviceType = 1;
//                        continue;
//                    }
//                }
//            }
//        }
        vo.setServiceList(serviceList);
//        if (serviceType == 0) {
//            vo.setServiceList(serviceList);
//        } else {
//            List<WorkerServiceVO> newServiceList = new ArrayList<>();
//            for (WorkerServiceVO service : serviceList) {
//                if (preparationId.equals(service.getServiceId())) {
//                    newServiceList.add(service);
//                }
//            }
//            vo.setServiceList(newServiceList);
//        }

        vo.setMonthOrdered(monthOrdered);
        vo.setYesterdayOrder(yesterdayOrder);
        vo.setTomorrowOrder(tomorrowOrder);
        vo.setCanOrder(canOrder);
        vo.setOrders(orders);
        return vo;
    }


    /**
     * check
     *
     * @param weddingDate
     * @param worker
     * @param workerMonthOrderLimitVO
     * @param weddingMonthOrder
     * @param thisMonthOrder
     * @param scheduleMap
     * @param thisMonthWorkerMonthOrderLimitVO
     * @param info
     * @return
     */
    private static WorkerInfoVO verifyWorkerScheduleNewForDay(String weddingDate, WorkerVO worker,
                                                              WorkerMonthOrderLimitVO workerMonthOrderLimitVO, List<WorkerWeddingOrderVO> weddingMonthOrder,
                                                              List<WorkerWeddingOrderVO> thisMonthOrder, Map<String, List<WorkerScheduleVO>> scheduleMap,
                                                              WorkerMonthOrderLimitVO thisMonthWorkerMonthOrderLimitVO, WorkerInfoVO info
            , String typeStr) {
        int daySchedule = worker.getDailyLimit();
        int canOrderType = 5;
        //0：职服设置0单，1：当天已接单，2：本月接单已满，3：月执行单已满,4：自己设置的休息日,5:可接单
        if (worker.getDailyLimit() == 0) {
            canOrderType = 0;
            daySchedule = 0;
        } else {
            List<WorkerScheduleVO> list = scheduleMap.get(weddingDate);
            //档期未被使用
            if (null == list || list.isEmpty()) {

            } else {
                if (verifyRest(list)) {
                    for (WorkerScheduleVO vo : list) {
                        if (1 == vo.getType()) {
                            canOrderType = 4;
                            daySchedule = 0;
                        }
                        if (2 == vo.getType()) {
                            canOrderType = 3;
                            daySchedule = 0;
                        }
                    }
                } else {
                    if (worker.getDailyLimit() <= list.size()) {
                        daySchedule = 0;
                        canOrderType = 1;
                    } else {
                        daySchedule = worker.getDailyLimit() - list.size();
                        canOrderType = 5;
                    }
                }
            }
        }


        if ("all".equals(typeStr)) {
            //存在限单设置
            if (null != thisMonthWorkerMonthOrderLimitVO) {
                //判断本月接单量
                if (null != thisMonthOrder && thisMonthWorkerMonthOrderLimitVO.getReceiptNum() <= thisMonthOrder.size()) {
                    daySchedule = 0;
                    canOrderType = 2;
                }
            }

            if (null != workerMonthOrderLimitVO) {
                //判断月执行量
                if (null != weddingMonthOrder && workerMonthOrderLimitVO.getLimitNum() <= weddingMonthOrder.size()) {
                    daySchedule = 0;
                    canOrderType = 3;
                }
            }
        }

        if (worker.getId().equals("c2f86469-a8d6-4e34-b298-ac02f4c34303") || worker.getId().equals("a1430acc-75a4-4f8c-9fb9-90475bcc6f0e")) {
            System.out.println("ni da ye");
        }

//        if (null != weddingDate && !weddingDate.isEmpty()) {
//            List<WorkerScheduleVO> list = scheduleMap.get(weddingDate);
//            //档期未被使用
//            if (null == list || list.isEmpty()) {
//                //@TODO
//                if (worker.getDailyType() == 1) {
//                    canOrderType = 2;
//                }
//                daySchedule = worker.getDailyLimit();
//            } else {
//                if (verifyRest(list)) {
//                    //@TODO 多次循环不知道是哪个最后出去，会影响最终结果
//                    for (WorkerScheduleVO vo : list) {
//                        if (1 == vo.getType()) {
//                            canOrderType = 4;
//                            daySchedule = 0;
//                        }
//                        if (2 == vo.getType()) {
//                            canOrderType = 3;
//                            daySchedule = 0;
//                        }
//                    }
//                } else {
//                    //档期按照日限单计算 此时list。size表示当天的订单数
//                    daySchedule = worker.getDailyLimit() - list.size() <= 0 ? 0 : worker.getDailyLimit() - list.size();
//                    //接单满了
//                    if (daySchedule == 0) {
//                        canOrderType = 1;
//                    } else {
//                        //存在限单设置
//                        if (null != thisMonthWorkerMonthOrderLimitVO) {
//                            //判断本月接单量
//                            if (null != thisMonthOrder && thisMonthWorkerMonthOrderLimitVO.getReceiptNum() <= thisMonthOrder.size()) {
//                                daySchedule = 0;
//                                canOrderType = 2;
//                            } else {
//                                if (null != workerMonthOrderLimitVO) {
//                                    //判断月执行量
//                                    if (null != weddingMonthOrder && workerMonthOrderLimitVO.getLimitNum() <= weddingMonthOrder.size()) {
//                                        daySchedule = worker.getDailyLimit() - list.size();
//                                        canOrderType = 3;
//                                    }
//                                }
//                            }
//                        }
//                    }
//                }
//            }
//        }
        info.setSchedule(daySchedule);
        info.setCanOrderType(canOrderType);
        //如果不存在婚期，则无法判断职业人是否有档期
        return info;
    }

    public static boolean verifyRest(List<WorkerScheduleVO> list) {
        boolean result = false;
        for (WorkerScheduleVO vo : list) {
            if (1 == vo.getType() || 2 == vo.getType()) {
                result = true;
            }
        }
        return result;
    }
}
